/*
 * OrderPagerAdapter.java
 * business
 *
 * Created by ChenTao on 2016/9/9.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.yidiandao.business.R;
import com.yidiandao.business.utils.UIUtils;

import java.util.ArrayList;
import java.util.List;

/** 我的订单 */
public class OrderPagerAdapter extends FragmentStatePagerAdapter {
    private final String[] mTitles;
    List<Fragment> list_fragment = new ArrayList<>();

    public OrderPagerAdapter(FragmentManager fm) {
        super(fm);
        list_fragment.clear();
        mTitles = UIUtils.getStringArray(R.array.order_title);
    }

    public void addFragment(Fragment fragment) {
        list_fragment.add(fragment);
    }

    @Override
    public Fragment getItem(int position) {
        return list_fragment.get(position);
    }

    @Override
    public int getCount() {
        return list_fragment.size();
    }

    //此方法用来显示tab上的名字
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}
